package com.br.estoque.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.br.estoque.bean.Situacao;

public class SituacaoDAO extends DataUtils {
	public List<Situacao> getAll(){
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		Situacao situacao = null;
		List<Situacao> lista = new ArrayList<Situacao>();
		try{
			conn = getConnection();
			stmt = conn.prepareStatement("SELECT * FROM situacao");
			rs = stmt.executeQuery();
			while(rs.next()){
				situacao = new Situacao();
				situacao.setId(rs.getInt("codigo"));
				situacao.setSituacao(rs.getString("situacao"
						));
				lista.add(situacao);
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			
		}
		return lista;
	}
}

